package org.yoki.edu.common.protocol.radius.attribute.attr.check;

import lombok.Getter;
import org.yoki.edu.common.protocol.radius.attribute.attr.type.IntegerTypeAttr;

/**
 * @author Sky$
 * @Description: TODO
 * @date 2018/1/15$ 14:54$
 */
public class NasPortTypeAttr extends IntegerTypeAttr {

    public static final int ATTR_TYPE = 61;

    @Override
    public int getAttrType() {
        return ATTR_TYPE;
    }

    public NasPortTypeEnum getNasPortType() {
        return NasPortTypeEnum.getByValue(this.value);
    }

    public enum NasPortTypeEnum {

        Async(0, "Async"),
        Sync(1, "Sync"),
        ISDN_Sync(2, "ISDN Sync"),
        ISDN_Async_V120(3, "ISDN Async V.120"),
        ISDN_Async_V110(4, "ISDN Async V.110"),
        Virtual(5, "Virtual"),
        PIAFS(6, "PIAFS"),
        HDLC_Clear_Channel(7, "HDLC Clear Channel"),
        X25(8, "X.25"),
        X75(9, "X.75"),
        G3Fax(10, "G.3 Fax"),
        SDSL(11, "Symmetric DSL"),
        ADSL_CAP(12, "ADSL-CAP - Asymmetric DSL, Carrierless Amplitude Phase Modulation"),
        ADSL_DMT(13, "ADSL-DMT - Asymmetric DSL, Discrete Multi-Tone"),
        IDSL(14, "IDSL - ISDN Digital Subscriber Line"),
        Ethernet(15, "Ethernet"),
        xDSL(16, "xDSL - Digital Subscriber Line of unknown type"),
        Cable(17, "Cable"),
        Wireless_Other(18, "Wireless - Other"),
        Wireless_IEEE_802_11(19, "Wireless - IEEE 802.11");

        @Getter
        private int value;
        @Getter
        private String name;

        NasPortTypeEnum(int value, String name) {
            this.value = value;
            this.name = name;
        }

        public static NasPortTypeEnum getByValue(Integer value) {
            if (null == value) {
                throw new IllegalArgumentException();
            }
            NasPortTypeEnum[] enums = NasPortTypeEnum.values();
            for (NasPortTypeEnum e : enums) {
                if (e.getValue() == value.intValue()) {
                    return e;
                }
            }
            return null;
        }

    }

}
